\(\int \tan ^2(e+f x) (a+b \tan ^2(e+f x)) \, dx\) [193]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [A] (verification not implemented)
   Maxima [A] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 21, antiderivative size = 40 \[ \int \tan ^2(e+f x) \left (a+b \tan ^2(e+f x)\right ) \, dx=-((a-b) x)+\frac {(a-b) \tan (e+f x)}{f}+\frac {b \tan ^3(e+f x)}{3 f} \]

[Out]

-(a-b)*x+(a-b)*tan(f*x+e)/f+1/3*b*tan(f*x+e)^3/f

Rubi [A] (verified)

Time = 0.04 (sec) , antiderivative size = 40, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 3, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.143, Rules used = {3712, 3554, 8} \[ \int \tan ^2(e+f x) \left (a+b \tan ^2(e+f x)\right ) \, dx=\frac {(a-b) \tan (e+f x)}{f}-x (a-b)+\frac {b \tan ^3(e+f x)}{3 f} \]

[In]

Int[Tan[e + f*x]^2*(a + b*Tan[e + f*x]^2),x]

[Out]

-((a - b)*x) + ((a - b)*Tan[e + f*x])/f + (b*Tan[e + f*x]^3)/(3*f)

Rule 8

Int[a_, x_Symbol] :> Simp[a*x, x] /; FreeQ[a, x]

Rule 3554

Int[((b_.)*tan[(c_.) + (d_.)*(x_)])^(n_), x_Symbol] :> Simp[b*((b*Tan[c + d*x])^(n - 1)/(d*(n - 1))), x] - Dis
t[b^2, Int[(b*Tan[c + d*x])^(n - 2), x], x] /; FreeQ[{b, c, d}, x] && GtQ[n, 1]

Rule 3712

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((A_.) + (C_.)*tan[(e_.) + (f_.)*(x_)]^2), x_Symbol] :> Simp
[C*((a + b*Tan[e + f*x])^(m + 1)/(b*f*(m + 1))), x] + Dist[A - C, Int[(a + b*Tan[e + f*x])^m, x], x] /; FreeQ[
{a, b, e, f, A, C, m}, x] && NeQ[A*b^2 + a^2*C, 0] &&  !LeQ[m, -1]

Rubi steps \begin{align*} \text {integral}& = \frac {b \tan ^3(e+f x)}{3 f}+(a-b) \int \tan ^2(e+f x) \, dx \\ & = \frac {(a-b) \tan (e+f x)}{f}+\frac {b \tan ^3(e+f x)}{3 f}+(-a+b) \int 1 \, dx \\ & = -((a-b) x)+\frac {(a-b) \tan (e+f x)}{f}+\frac {b \tan ^3(e+f x)}{3 f} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.03 (sec) , antiderivative size = 65, normalized size of antiderivative = 1.62 \[ \int \tan ^2(e+f x) \left (a+b \tan ^2(e+f x)\right ) \, dx=-\frac {a \arctan (\tan (e+f x))}{f}+\frac {b \arctan (\tan (e+f x))}{f}+\frac {a \tan (e+f x)}{f}-\frac {b \tan (e+f x)}{f}+\frac {b \tan ^3(e+f x)}{3 f} \]

[In]

Integrate[Tan[e + f*x]^2*(a + b*Tan[e + f*x]^2),x]

[Out]

-((a*ArcTan[Tan[e + f*x]])/f) + (b*ArcTan[Tan[e + f*x]])/f + (a*Tan[e + f*x])/f - (b*Tan[e + f*x])/f + (b*Tan[
e + f*x]^3)/(3*f)

Maple [A] (verified)

Time = 0.04 (sec) , antiderivative size = 38, normalized size of antiderivative = 0.95

method result size
norman \(\left (-a +b \right ) x +\frac {\left (a -b \right ) \tan \left (f x +e \right )}{f}+\frac {b \tan \left (f x +e \right )^{3}}{3 f}\) \(38\)
parallelrisch \(-\frac {-b \tan \left (f x +e \right )^{3}+3 a f x -3 b f x -3 \tan \left (f x +e \right ) a +3 b \tan \left (f x +e \right )}{3 f}\) \(46\)
derivativedivides \(\frac {\frac {b \tan \left (f x +e \right )^{3}}{3}+\tan \left (f x +e \right ) a -b \tan \left (f x +e \right )+\left (-a +b \right ) \arctan \left (\tan \left (f x +e \right )\right )}{f}\) \(47\)
default \(\frac {\frac {b \tan \left (f x +e \right )^{3}}{3}+\tan \left (f x +e \right ) a -b \tan \left (f x +e \right )+\left (-a +b \right ) \arctan \left (\tan \left (f x +e \right )\right )}{f}\) \(47\)
parts \(\frac {a \left (\tan \left (f x +e \right )-\arctan \left (\tan \left (f x +e \right )\right )\right )}{f}+\frac {b \left (\frac {\tan \left (f x +e \right )^{3}}{3}-\tan \left (f x +e \right )+\arctan \left (\tan \left (f x +e \right )\right )\right )}{f}\) \(54\)
risch \(-a x +b x +\frac {2 i \left (3 a \,{\mathrm e}^{4 i \left (f x +e \right )}-6 b \,{\mathrm e}^{4 i \left (f x +e \right )}+6 a \,{\mathrm e}^{2 i \left (f x +e \right )}-6 b \,{\mathrm e}^{2 i \left (f x +e \right )}+3 a -4 b \right )}{3 f \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right )^{3}}\) \(83\)

[In]

int(tan(f*x+e)^2*(a+b*tan(f*x+e)^2),x,method=_RETURNVERBOSE)

[Out]

(-a+b)*x+(a-b)*tan(f*x+e)/f+1/3*b*tan(f*x+e)^3/f

Fricas [A] (verification not implemented)

none

Time = 0.25 (sec) , antiderivative size = 38, normalized size of antiderivative = 0.95 \[ \int \tan ^2(e+f x) \left (a+b \tan ^2(e+f x)\right ) \, dx=\frac {b \tan \left (f x + e\right )^{3} - 3 \, {\left (a - b\right )} f x + 3 \, {\left (a - b\right )} \tan \left (f x + e\right )}{3 \, f} \]

[In]

integrate(tan(f*x+e)^2*(a+b*tan(f*x+e)^2),x, algorithm="fricas")

[Out]

1/3*(b*tan(f*x + e)^3 - 3*(a - b)*f*x + 3*(a - b)*tan(f*x + e))/f

Sympy [A] (verification not implemented)

Time = 0.10 (sec) , antiderivative size = 54, normalized size of antiderivative = 1.35 \[ \int \tan ^2(e+f x) \left (a+b \tan ^2(e+f x)\right ) \, dx=\begin {cases} - a x + \frac {a \tan {\left (e + f x \right )}}{f} + b x + \frac {b \tan ^{3}{\left (e + f x \right )}}{3 f} - \frac {b \tan {\left (e + f x \right )}}{f} & \text {for}\: f \neq 0 \\x \left (a + b \tan ^{2}{\left (e \right )}\right ) \tan ^{2}{\left (e \right )} & \text {otherwise} \end {cases} \]

[In]

integrate(tan(f*x+e)**2*(a+b*tan(f*x+e)**2),x)

[Out]

Piecewise((-a*x + a*tan(e + f*x)/f + b*x + b*tan(e + f*x)**3/(3*f) - b*tan(e + f*x)/f, Ne(f, 0)), (x*(a + b*ta
n(e)**2)*tan(e)**2, True))

Maxima [A] (verification not implemented)

none

Time = 0.33 (sec) , antiderivative size = 41, normalized size of antiderivative = 1.02 \[ \int \tan ^2(e+f x) \left (a+b \tan ^2(e+f x)\right ) \, dx=\frac {b \tan \left (f x + e\right )^{3} - 3 \, {\left (f x + e\right )} {\left (a - b\right )} + 3 \, {\left (a - b\right )} \tan \left (f x + e\right )}{3 \, f} \]

[In]

integrate(tan(f*x+e)^2*(a+b*tan(f*x+e)^2),x, algorithm="maxima")

[Out]

1/3*(b*tan(f*x + e)^3 - 3*(f*x + e)*(a - b) + 3*(a - b)*tan(f*x + e))/f

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 269 vs. \(2 (38) = 76\).

Time = 0.56 (sec) , antiderivative size = 269, normalized size of antiderivative = 6.72 \[ \int \tan ^2(e+f x) \left (a+b \tan ^2(e+f x)\right ) \, dx=-\frac {3 \, a f x \tan \left (f x\right )^{3} \tan \left (e\right )^{3} - 3 \, b f x \tan \left (f x\right )^{3} \tan \left (e\right )^{3} - 9 \, a f x \tan \left (f x\right )^{2} \tan \left (e\right )^{2} + 9 \, b f x \tan \left (f x\right )^{2} \tan \left (e\right )^{2} + 3 \, a \tan \left (f x\right )^{3} \tan \left (e\right )^{2} - 3 \, b \tan \left (f x\right )^{3} \tan \left (e\right )^{2} + 3 \, a \tan \left (f x\right )^{2} \tan \left (e\right )^{3} - 3 \, b \tan \left (f x\right )^{2} \tan \left (e\right )^{3} + 9 \, a f x \tan \left (f x\right ) \tan \left (e\right ) - 9 \, b f x \tan \left (f x\right ) \tan \left (e\right ) + b \tan \left (f x\right )^{3} - 6 \, a \tan \left (f x\right )^{2} \tan \left (e\right ) + 9 \, b \tan \left (f x\right )^{2} \tan \left (e\right ) - 6 \, a \tan \left (f x\right ) \tan \left (e\right )^{2} + 9 \, b \tan \left (f x\right ) \tan \left (e\right )^{2} + b \tan \left (e\right )^{3} - 3 \, a f x + 3 \, b f x + 3 \, a \tan \left (f x\right ) - 3 \, b \tan \left (f x\right ) + 3 \, a \tan \left (e\right ) - 3 \, b \tan \left (e\right )}{3 \, {\left (f \tan \left (f x\right )^{3} \tan \left (e\right )^{3} - 3 \, f \tan \left (f x\right )^{2} \tan \left (e\right )^{2} + 3 \, f \tan \left (f x\right ) \tan \left (e\right ) - f\right )}} \]

[In]

integrate(tan(f*x+e)^2*(a+b*tan(f*x+e)^2),x, algorithm="giac")

[Out]

-1/3*(3*a*f*x*tan(f*x)^3*tan(e)^3 - 3*b*f*x*tan(f*x)^3*tan(e)^3 - 9*a*f*x*tan(f*x)^2*tan(e)^2 + 9*b*f*x*tan(f*
x)^2*tan(e)^2 + 3*a*tan(f*x)^3*tan(e)^2 - 3*b*tan(f*x)^3*tan(e)^2 + 3*a*tan(f*x)^2*tan(e)^3 - 3*b*tan(f*x)^2*t
an(e)^3 + 9*a*f*x*tan(f*x)*tan(e) - 9*b*f*x*tan(f*x)*tan(e) + b*tan(f*x)^3 - 6*a*tan(f*x)^2*tan(e) + 9*b*tan(f
*x)^2*tan(e) - 6*a*tan(f*x)*tan(e)^2 + 9*b*tan(f*x)*tan(e)^2 + b*tan(e)^3 - 3*a*f*x + 3*b*f*x + 3*a*tan(f*x) -
 3*b*tan(f*x) + 3*a*tan(e) - 3*b*tan(e))/(f*tan(f*x)^3*tan(e)^3 - 3*f*tan(f*x)^2*tan(e)^2 + 3*f*tan(f*x)*tan(e
) - f)

Mupad [B] (verification not implemented)

Time = 11.79 (sec) , antiderivative size = 37, normalized size of antiderivative = 0.92 \[ \int \tan ^2(e+f x) \left (a+b \tan ^2(e+f x)\right ) \, dx=\frac {\frac {b\,{\mathrm {tan}\left (e+f\,x\right )}^3}{3}+\left (a-b\right )\,\mathrm {tan}\left (e+f\,x\right )-f\,x\,\left (a-b\right )}{f} \]

[In]

int(tan(e + f*x)^2*(a + b*tan(e + f*x)^2),x)

[Out]

(tan(e + f*x)*(a - b) + (b*tan(e + f*x)^3)/3 - f*x*(a - b))/f